﻿using Microsoft.AspNetCore.Mvc;
using Sprout.Schedule.Dtos;
using Sprout.Schedule.Web.Jobs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Sprout.Schedule.Web.Controllers
{
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class ApiJobController : ControllerBase
    {
        /// <summary>
        /// API任务测试-异步
        /// </summary>
        /// <param name="jobParams"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task ApiJobTest2(ApiJobParamsDto jobParams)
        {
            //ApiJobTest apiJobTest = ServiceLocator.GetService<ApiJobTest>();
            ApiJobTest apiJobTest = new ApiJobTest();
            //异步执行的调用
            await apiJobTest.ExecuteAsync(jobParams);

        }

        /// <summary>
        /// API任务测试-同步
        /// </summary>
        /// <param name="jobParams"></param>
        /// <returns></returns>
        [HttpPost]
        public void ApiJobTest1(ApiJobParamsDto jobParams)
        {
            //ApiJobTest apiJobTest = ServiceLocator.GetService<ApiJobTest>();
            ApiJobTest apiJobTest = new ApiJobTest();
            //同步执行的调用
            apiJobTest.Execute(jobParams);

        }
    }
}
